<template>
	<view style="width: 99%;">
		<view style="display: flex; align-items: center;justify-content: space-between;">
			<view style="display: flex; align-items: center;">
				<view>{{memberManageMembertype}}（共{{memberlisttotal}}）</view>
				<view><button size="mini" type="default" @click="memberMigrate">迁移会员</button></view>
				<view style="width: 1000rpx;"> <uni-search-bar placeholder="请填写搜索关键字" v-model="searchkeyword"
						@input="searchkeywordchange"></uni-search-bar></view>
			</view>
			<view>
				<button @click="addmember" size="mini" type="primary" style="margin-left: 30rpx;">添加会员</button>
				<button @click="importmember" size="mini" type="primary" style="margin-left: 30rpx;">导入会员信息</button>
				<button @click="put" size="mini" type="primary" style="margin-left: 30rpx;">导出会员信息</button>
			</view>
		</view>
		<uni-table ref="memberlisttable" :border="true" class="table-container" style="width: 100%;" type="selection"
			@selection-change="membertableselectionchange">
			<uni-tr>
				<uni-th></uni-th>
				<uni-th>member_id</uni-th>
				<!-- 				<uni-th>corp_id</uni-th>
				<uni-th>shop_id</uni-th> -->
				<uni-th>
					<view style="color: blue;">
						<picker mode="selector" :range="shoplist" @change="shopsearchchange" @click="getshoplist">
							{{searchkeyshopname}}</uni-easyinput>
							<view v-if="searchkeyshopname==''">加盟店</view>
						</picker>
					</view>
				</uni-th>
				<!-- 				<uni-th>member_id</uni-th> -->
				<uni-th>原会员卡号</uni-th>
				<uni-th>姓名</uni-th>
				<uni-th>性别</uni-th>
				<uni-th>手机号</uni-th>
				<uni-th>余额</uni-th>
				<uni-th>积分</uni-th>
				<uni-th>代金券</uni-th>
				<uni-th>消费总额</uni-th>
				<uni-th>所在地区</uni-th>
				<uni-th>身份证号</uni-th>
				<uni-th>生日</uni-th>
				<uni-th>学校</uni-th>
				<uni-th>年级</uni-th>
				<uni-th>班</uni-th>
				<uni-th>家庭住址</uni-th>
				<uni-th>备注</uni-th>
				<uni-th>注册时间</uni-th>
			</uni-tr>
			<uni-tr v-for="(item,index) in memberlist" :key="index">
				<uni-td>
					<view>
						<image src="/static/edit.jpg" style="width: 40rpx; height: 40rpx;"
							@click="popfunctionwindow(item)">
						</image>
					</view>
				</uni-td>
				<uni-td>
					<view>{{item.member_id}}</view>
				</uni-td>
				<!-- 				<uni-td>{{item.corp_id}}</uni-td>
				<uni-td>{{item.shop_id}}</uni-td> -->
				<uni-td>{{item.shop_name}}</uni-td>
				<!-- <uni-td>{{item.member_id}}</uni-td> -->
				<uni-td>{{item.old_memberno}}</uni-td>
				<uni-td>{{item.name}}</uni-td>
				<uni-td>{{['男','女'][item.gender-1]}}</uni-td>
				<uni-td>{{item.mobile}}</uni-td>
				<uni-td>
					<view @click="balance(item)">{{item.balance}}</view>
				</uni-td>
				<uni-td>
					<view @click="balance(item)">{{item.points}}</view>
				</uni-td>
				<uni-td>
					<view @click="balance(item)">{{item.voucher}}</view>
				</uni-td>
				<uni-td>
					<view @click="balance(item)">{{item.consumption}}</view>
				</uni-td>
				<uni-td> {{item.area_name}}</uni-td>
				<uni-td>{{item.id_card}}</uni-td>
				<uni-td>{{item.birthday}}</uni-td>
				<uni-td>{{item.school_name}}</uni-td>
				<uni-td>{{item.grade_name}}</uni-td>
				<uni-td>{{item.class_name}}</uni-td>
				<uni-td>{{item.home_address}}</uni-td>
				<uni-td>{{item.basic_info}}</uni-td>
				<uni-td>{{item.create_time}}</uni-td>
			</uni-tr>
		</uni-table>
		<view style="display: flex; align-items: center;">
			<view style="width: 100%; display: flex;justify-content: center; align-items: center;">
				<pages_button @currentpage="memberlistpagepagechange" :pages="Math.ceil(memberlisttotal/pagesize)" />
			</view>
		</view>



		<!-- 操作功能弹窗开始 -->
		<uni-popup ref="functionwindow">
			<view class="popwindowstyle">
				{{currentmemberinfo.name}}
				<cc-wxBtn :title="'修改'" @menuClick="editme(currentmemberinfo)"></cc-wxBtn>
				<cc-wxBtn :title="'删除'" @menuClick="delme(currentmemberinfo)"></cc-wxBtn>
				<cc-wxBtn :title="'检查记录'" @menuClick="viewme"></cc-wxBtn>
				<cc-wxBtn :title="'充值'" @menuClick="popwindow('balanceRecharge')"></cc-wxBtn>
				<cc-wxBtn :title="'已充值消费'" @menuClick="popwindow('RechargedConsumption')"></cc-wxBtn>
				<cc-wxBtn :title="'非充值消费'" @menuClick="popwindow('unRechargedConsumption')"></cc-wxBtn>
				<cc-wxBtn :title="'积分兑换'" @menuClick="popwindow('pointsDec')"></cc-wxBtn>
			</view>
		</uni-popup>
		<!-- 操作功能弹窗结束 -->

		<!-- 修改会员信息开始 -->
		<uni-popup ref="editMemberInfo">
			<view
				style="width: 50vw; max-width: 1000rpx; height: auto; background-color: white; border-radius: 30rpx; padding: 30rpx;">
				<view>
					修改会员信息
					<uni-table ref="editmemberinfo" style="width: 100%;">
						<uni-tr>
							<uni-th> </uni-th>
							<uni-th> </uni-th>
						</uni-tr>
						<uni-tr>
							<uni-td>member_id </uni-td>
							<uni-td>{{currentmemberinfo.member_id}}</uni-td>
						</uni-tr>
						<uni-tr>
							<uni-td>姓名</uni-td>
							<uni-td>{{currentmemberinfo.name}} </uni-td>
						</uni-tr>
						<uni-tr>
							<uni-td>加盟店</uni-td>
							<uni-td>{{currentmemberinfo.shop_name}}></uni-td>
						</uni-tr>
					</uni-table>
					<view style="display: flex;justify-content: space-between; margin-top: 50rpx;">
						<button type="warn" size="mini">取消</button>
						<button type="primary" size="mini">确定</button>
					</view>
				</view>
			</view>
		</uni-popup>
		<!-- 修改会员信息结束 -->

		<!-- 查看检查记录开始 -->
		<uni-popup ref="viewSightDiopterLog">
			<view
				style="width: 80vw; height: auto; min-height: 70vh; max-height: 90vh; background-color: white; border-radius: 30rpx; padding: 30rpx;">
				<view>
					{{viewcard}} - {{currentmemberinfo.name}}
				</view>
				<view style="display: flex;justify-content: space-between;">
					<button type="default" size="mini" @click="sightlog()">视力检查记录</button>
					<button type="default" size="mini" @click="selfsightlog()">视力自测记录</button>
					<button type="default" size="mini" @click="diopterlog()">验光检查记录</button>
				</view>
				<view v-if="viewcard!='屈光度检查记录'">
					<view style="width: 100%;">
						<uni-table ref="diopter">
							<uni-tr>
								<uni-th>时间</uni-th>
								<uni-th>右眼裸眼视力</uni-th>
								<uni-th>左眼裸眼视力</uni-th>
								<uni-th>右眼矫正视力</uni-th>
								<uni-th>左眼矫正视力</uni-th>
								<uni-th v-if="viewcard!='视力自测记录'">检测人</uni-th>
							</uni-tr>
							<uni-tr v-for="(item,index) in membersightlist" :key="index">
								<uni-td>{{item.create_time}}</uni-td>
								<uni-td>{{item.rns}}</uni-td>
								<uni-td>{{item.lns}}</uni-td>
								<uni-td>{{item.rnc}}</uni-td>
								<uni-td>{{item.lnc}}</uni-td>
								<uni-td v-if="viewcard!='视力自测记录'">{{item.shop_account_name}}</uni-td>
							</uni-tr>
						</uni-table>
						<button type="primary" @click="addsight">添加新记录</button>
					</view>
				</view>
				<view v-else>
					<view style="width: 100%;">
						<uni-table ref="sight">
							<uni-tr>
								<uni-th>时间</uni-th>
								<uni-th>右眼</uni-th>
								<uni-th>左眼</uni-th>
								<uni-th>PD</uni-th>
								<uni-th>检测人</uni-th>
							</uni-tr>
							<uni-tr v-for="(item,index) in memberdiopterlist" :key="index">
								<uni-td>{{item.create_time}}</uni-td>
								<uni-td>{{(item.rs*1).toFixed(2)}}*{{(item.rc*1).toFixed(2)}}/{{item.ra}}</uni-td>
								<uni-td>{{(item.ls*1).toFixed(2)}}*{{(item.lc*1).toFixed(2)}}/{{item.la}}</uni-td>
								<uni-td>{{item.pd}}</uni-td>
								<uni-td>{{item.shop_account_name}}</uni-td>
							</uni-tr>
						</uni-table>
					</view>
				</view>
			</view>
		</uni-popup>
		<!-- 查看检查记录结束 -->


		<!-- 迁移会员弹窗开始 -->
		<uni-popup ref="memberManagewindow">
			<view
				style="width: 50vw; max-width: 1000rpx; height: auto; background-color: white; border-radius: 30rpx; padding: 30rpx;">
				请选择迁移到的加盟店
				<view>
					<view v-for="(item,index) in franchiselist" :key="index">
						<cc-wxBtn :title="item.company_name" @menuClick="memberManageSubmit(item)"></cc-wxBtn>
					</view>
				</view>

			</view>
		</uni-popup>
		<!-- 迁移会员弹窗结束 -->

		<!-- 会员余额操作开始 -->
		<uni-popup ref="memberbalance">
			<view style="width: 80vw; height: auto; background-color: white; border-radius: 30rpx; padding: 30rpx;">
				<view align="center"> {{balanceoperatetype}} -- {{currentmemberinfo.name}}</view>
				<view>
					<view style="height: 80vh; overflow-y: auto;">
						<uni-table>
							<uni-tr>
								<uni-th> id </uni-th>
								<uni-th> 时间 </uni-th>
								<uni-th> 余额 </uni-th>
								<uni-th> 积分 </uni-th>
								<uni-th> 代金券 </uni-th>
								<uni-th> 备注 </uni-th>
								<uni-th> 操作人 </uni-th>
							</uni-tr>
							<uni-tr v-for=" (item,index) in this.memberbalancelog" :key="index">
								<uni-td> {{item.id}}</uni-td>
								<uni-td> {{item.datetime}}</uni-td>
								<uni-td> {{item.balancenumber}}</uni-td>
								<uni-td> {{item.pointsnumber}}</uni-td>
								<uni-td> {{item.vouchernumber}}</uni-td>
								<uni-td> {{item.remark}}</uni-td>
								<uni-td> {{item.operater_name}}</uni-td>
							</uni-tr>
						</uni-table>
					</view>
					<!-- <button @click="addmemberbalancelog" type="primary">添加</button> -->
				</view>

			</view>
		</uni-popup>
		<!-- 会员余额操作结束 -->

		<!-- 添加余额窗口开始 -->
		<uni-popup ref="addmemberbalancelog">
			<view
				style="width: 50vw; max-width: 1000rpx; height: auto; background-color: white; border-radius: 30rpx; padding: 30rpx;">
				<view>
					<view align="center"> {{balanceoperatetype}} </view>
					<view style="margin-top: 50rpx; display: flex; al ign-items: center;">
						<view>余额：</view>
						<uni-easyinput placeholder="请填写变更余额数量,充值填写正值,消费填写负值" type="number"
							v-model="balancenumber"></uni-easyinput>
					</view>
					<view style="margin-top: 50rpx; display: flex; align-items: center;">
						<view>积分：</view>
						<uni-easyinput placeholder="请填写变更余额数量,充值填写正值,消费填写负值" type="number"
							v-model="pointsnumber"></uni-easyinput>
					</view>
					<view style="margin-top: 50rpx; display: flex; align-items: center;">
						<view>代金券：</view>
						<uni-easyinput placeholder="请填写变更余额数量,充值填写正值,消费填写负值" type="number"
							v-model="vouchernumber"></uni-easyinput>
					</view>
					<view style="margin-top: 50rpx;">
						<uni-easyinput type="textarea" placeholder="请填写备注信息" v-model="balanceremark"></uni-easyinput>
					</view>
					<view style="margin-top: 50rpx;">
						<cc-wxBtn :title="operater.name" @menuClick="selecterpcorpaccount"></cc-wxBtn>
					</view>
					<view style="width: 100%; display: flex;justify-content: space-between; margin-top: 50rpx;">
						<button type="warn" size="mini" @click="balancecancle">取消</button>
						<button type="primary" size="mini" @click="balancesubmit(item)">确定</button>
					</view>
				</view>
			</view>
		</uni-popup>
		<!-- 添加余额窗口结束 -->

		<!-- 选择操作人窗口开始 -->
		<uni-popup ref="selectmemberbalancewindow">
			<view
				style="width: 50vw; max-width: 1000rpx; height: auto; max-height: 90vh; background-color: white; border-radius: 30rpx; padding: 30rpx;">
				<view>
					<uni-search-bar v-model="searchkeyword" @input="geterpcorpaccount"></uni-search-bar>
					<view style="height: 80vh; overflow-y: auto;">
						<view v-for="(item,index) in erpcorpaccount" :key="index">
							<cc-wxBtn :title="item.name" @menuClick="operatselectsubmit(item)"></cc-wxBtn>
						</view>
					</view>
				</view>

			</view>
		</uni-popup>
		<!-- 选择操作人窗口结束 -->

		<!-- 添加会员开始 -->
		<uni-popup ref="addmemberwindow" :mask-click="false">
			<view
				style="width: 50vw; max-width: 1000rpx; height: auto; max-height: 90vh; background-color: white; border-radius: 30rpx; padding: 30rpx; overflow-y: auto;">
				<view>
					{{addmembertitle}}
				</view>
				<uni-table>
					<tr>
						<td>
							<view style="margin-top: 30rpx;">请选择加盟店</view>
						</td>
						<td>
							<view style="margin-top: 30rpx;" @click="selectshop">{{newmemberinfo.shop_name}}</view>
						</td>
					</tr>
					<tr>
						<td>
							<view style="margin-top: 30rpx;">姓名</view>
						</td>
						<td>
							<view style="margin-top: 30rpx;"><uni-easyinput placeholder="姓名"
									v-model="newmemberinfo.name"></uni-easyinput></view>
						</td>
					</tr>
					<tr>
						<td>
							<view style="margin-top: 30rpx;">学籍号</view>
						</td>
						<td>
							<view style="margin-top: 30rpx;"><uni-easyinput placeholder="学籍号(国家统一学籍号为G+身份证号)"
									v-model="newmemberinfo.student_no" @blur="anastudent_no"></uni-easyinput>
							</view>
						</td>
					</tr>
					<tr>
						<td>
							<view style="margin-top: 30rpx;">身份证号</view>
						</td>
						<td>
							<view style="margin-top: 30rpx;"><uni-easyinput placeholder="身份证号"
									v-model="newmemberinfo.id_card" @blur="checkid_card"></uni-easyinput>
							</view>
						</td>
					</tr>
					<tr>
						<td>
							<view style="margin-top: 30rpx;">性别</view>
						</td>
						<td>
							<uni-section title="">
								<uni-data-checkbox v-model="newmemberinfo.gender"
									:localdata="sexrange"></uni-data-checkbox>
							</uni-section>
						</td>
					</tr>
					<uni-tr>
						<td>
							<view style="margin-top: 30rpx;">出生日期</view>
						</td>
						<td>
							<picker mode="date" value="newmemberinfo.birthday" @change="bindDateChange"
								:end="currentDate">
								<view style="height: 150%; width: 100%; align-items: end;">
									{{newmemberinfo.birthday}}
								</view>
							</picker>
						</td>
					</uni-tr>
					<tr>
						<td>
							<view style="margin-top: 30rpx;">原会员卡号</view>
						</td>
						<td>
							<view style="margin-top: 30rpx;"><uni-easyinput placeholder="原会员卡号"
									v-model="newmemberinfo.old_memberno"></uni-easyinput></view>
						</td>
					</tr>

					<tr>
						<td>
							<view style="margin-top: 30rpx;">余额</view>
						</td>
						<td>
							<view style="margin-top: 30rpx;"><uni-easyinput placeholder="余额" type="number"
									v-model="newmemberinfo.balance"></uni-easyinput></view>
						</td>
					</tr>
					<tr>
						<td>
							<view style="margin-top: 30rpx;">积分</view>
						</td>
						<td>
							<view style="margin-top: 30rpx;"><uni-easyinput placeholder="积分"
									v-model="newmemberinfo.points" type="number"></uni-easyinput></view>
						</td>
					</tr>
					<tr>
						<td>
							<view style="margin-top: 30rpx;">代金券</view>
						</td>
						<td>
							<view style="margin-top: 30rpx;"><uni-easyinput placeholder="代金券"
									v-model="newmemberinfo.voucher" type="number"></uni-easyinput></view>
						</td>
					</tr>

					<tr>
						<td>
							<view style="margin-top: 30rpx;">消费总额</view>
						</td>
						<td>
							<view style="margin-top: 30rpx;"><uni-easyinput placeholder="消费总额"
									v-model="newmemberinfo.consumption" type="number"></uni-easyinput></view>
						</td>
					</tr>
					<tr>
						<td>
							<view style="margin-top: 30rpx;">所在地区</view>
						</td>
						<td>
							<view style="margin-top: 30rpx;" @click="arealist">{{newmemberinfo.area_name}}</view>
						</td>
					</tr>
					<tr>
						<td>
							<view style="margin-top: 30rpx;">学校</view>
						</td>
						<td>
							<view style="margin-top: 30rpx;"><uni-easyinput placeholder="学校"
									v-model="newmemberinfo.school_name"></uni-easyinput></view>
						</td>
					</tr>
					<tr>
						<td>
							<view style="margin-top: 30rpx;">年级</view>
						</td>
						<td>
							<view style="margin-top: 30rpx;"><uni-easyinput placeholder="年级"
									v-model="newmemberinfo.grade_name"></uni-easyinput></view>
						</td>
					</tr>
					<tr>
						<td>
							<view style="margin-top: 30rpx;">班</view>
						</td>
						<td>
							<view style="margin-top: 30rpx;"><uni-easyinput placeholder="班"
									v-model="newmemberinfo.class_name"></uni-easyinput></view>
						</td>
					</tr>

					<tr>
						<td>
							<view style="margin-top: 30rpx;">家庭住址</view>
						</td>
						<td>
							<view style="margin-top: 30rpx;"><uni-easyinput placeholder="家庭住址"
									v-model="newmemberinfo.home_address"></uni-easyinput>
							</view>
						</td>
					</tr>
					<tr>
						<td>
							<view style="margin-top: 30rpx;">联系人</view>
						</td>
						<td>
							<view style="margin-top: 30rpx;"><uni-easyinput placeholder="联系人/监护人"
									v-model="newmemberinfo.contacts" type="number"></uni-easyinput></view>
						</td>
					</tr>
					<tr>
						<td>
							<view style="margin-top: 30rpx;">手机号</view>
						</td>
						<td>
							<view style="margin-top: 30rpx;"><uni-easyinput placeholder="手机号"
									v-model="newmemberinfo.mobile" type="number"></uni-easyinput></view>
						</td>
					</tr>


					<uni-tr>
						<td>
							<view style="margin-top: 30rpx;">备注</view>
						</td>
						<td>
							<uni-easyinput type="textarea" v-model="newmemberinfo.basic_info"></uni-easyinput>
						</td>
					</uni-tr>
				</uni-table>
				<view style="display: flex;justify-content: space-around; margin: 30rpx;">
					<button type="warn" size="mini" @click="addmembercancle">取消</button>
					<button type="primary" size="mini" @click="addmembersubmit">确定</button>
				</view>
			</view>
		</uni-popup>
		<!-- 添加会员结束 -->

		<!-- 批量导入会员开始 -->
		<uni-popup ref="importmemberwindow" :mask-click="false">
			<view
				style="width: 95vw; height: auto; max-height: 90vh; background-color: white; border-radius: 30rpx; padding: 30rpx; overflow-y: auto;">
				<view>
					批量导入会员信息
				</view>
				<view style="display: flex;justify-content: space-between;">
					<view>
						<button type="primary" size="mini" style="margin-top: 30rpx; margin-right: 30rpx;"
							@click="read">选择导入文件</button>
						<button type="primary" size="mini" style="margin-top: 30rpx; margin-right: 30rpx;"
							@click="selectshop">{{newmemberinfo.shop_name}}</button>
						<button type="primary" size="mini" style="margin-top: 30rpx; margin-right: 30rpx;"
							@click="arealist">{{newmemberinfo.area_name}}</button>
						<button type="primary" size="mini" @click="importmembersubmit">确认导入</button>
					</view>
					<view style="margin-right: 50rpx;">
						<button type="warn" size="mini" @click="importmembercancle">关闭</button>
					</view>
				</view>
				<uni-table style="height: 80vh;">
					<uni-tr>
						<uni-th>导入状态</uni-th>
						<uni-th>序号</uni-th>
						<uni-th>姓名</uni-th>
						<uni-th>性别</uni-th>
						<uni-th>原会员卡号</uni-th>
						<uni-th>余额</uni-th>
						<uni-th>积分</uni-th>
						<uni-th>代金券</uni-th>
						<uni-th>消费总额</uni-th>
						<uni-th>学校</uni-th>
						<uni-th>年级</uni-th>
						<uni-th>班</uni-th>
						<uni-th>身份证号</uni-th>
						<uni-th>学籍号</uni-th>
						<uni-th>家庭住址</uni-th>
						<uni-th>联系人</uni-th>
						<uni-th>手机号</uni-th>
						<uni-th>出生日期</uni-th>
						<uni-th>备注</uni-th>
					</uni-tr>
					<uni-tr v-for="(item,index) in exceldata" :key="index">
						<uni-td>{{item.导入状态}}</uni-td>
						<uni-td>{{index+1}}</uni-td>
						<uni-td>{{item.姓名}}</uni-td>
						<uni-td>{{item.性别}}</uni-td>
						<uni-td>{{item.原会员卡号}}</uni-td>
						<uni-td>{{item.余额}}</uni-td>
						<uni-td>{{item.积分}}</uni-td>
						<uni-td>{{item.代金券}}</uni-td>
						<uni-td>{{item.消费总额}}</uni-td>
						<uni-td>{{item.学校}}</uni-td>
						<uni-td>{{item.年级}}</uni-td>
						<uni-td>{{item.班}}</uni-td>
						<uni-td>{{item.身份证号}}</uni-td>
						<uni-td>{{item.学籍号}}</uni-td>
						<uni-td>{{item.家庭住址}}</uni-td>
						<uni-td>{{item.联系人}}</uni-td>
						<uni-td>{{item.手机号}}</uni-td>
						<uni-td>{{item.出生日期}}</uni-td>
						<uni-td>{{item.备注}}</uni-td>
					</uni-tr>
				</uni-table>
			</view>
		</uni-popup>
		<!-- 批量导入会员结束 -->

		<uni-popup ref="arealistwindow">
			<view
				style="width: 50vw; max-width: 1000rpx; height: auto; max-height: 90vh; background-color: white; border-radius: 30rpx; padding: 30rpx;">
				<arealist @areaselectsubmit="areaselectsubmit"></arealist>
			</view>
		</uni-popup>

		<!-- 选择加盟店弹窗开始 -->

		<uni-popup ref="shopmanagewindow">
			<view
				style="width: 50vw; max-width: 1000rpx; height: auto; max-height: 90vh; background-color: white; border-radius: 30rpx; padding: 30rpx;">
				<shopmemage @shopselectsubmit="shopselectsubmit"></shopmemage>
			</view>
		</uni-popup>
		<!-- 选择加盟店弹窗结束 -->


		<!-- 进度条弹窗开始 -->
		<uni-popup ref="progresspercentwindow">
			<view
				style="width: 50vw; max-width: 1000rpx; height: auto; max-height: 90vh; background-color: white; border-radius: 30rpx; padding: 30rpx;">
				<progress :percent="progresspercent" />
				<view style="width:100%;display:flex;justify-content: space-around;">
					<view> {{percentnow}}/{{percenttotal}}</view>
					<view>{{progresspercent}}%</view>
				</view>
			</view>
		</uni-popup>
		<!-- 进度条弹窗结束 -->

		<!-- 导出信息弹窗开始 -->
		<uni-popup ref="exportdatawindow">
			<view
				style="width: 50vw; max-width: 1000rpx; height: auto;  overflow-y: auto; max-height: 90vh; background-color: white; border-radius: 30rpx; padding: 30rpx;">
				<view>
					<view>导出数据</view>
					<cc-wxBtn v-for=" (item,index) in exportdatalist" :key="index"
						:title="(index*1000+1)+'-'+(index*1000+1000)" @menuClick="exportselect(index)"></cc-wxBtn>
				</view>
			</view>
		</uni-popup>
		<!-- 导出信息弹窗结束 -->

		<!-- 添加视力弹窗开始 -->
		<uni-popup ref="addsightwindow">
			<view
				style="width: 50vw; max-width: 1000rpx; height: 90vh overflow-y: auto;background-color: white; border-radius: 30rpx; padding: 30rpx;">
				<view>
					<view>添加视力数据</view>
					<uni-table style="height: 100%;">
						<uni-tr>
							<uni-th>
							</uni-th>
							<uni-th>
								右眼
							</uni-th>
							<uni-th>
								左眼
							</uni-th>
						</uni-tr>
						<uni-tr>
							<uni-td>
								裸眼视力
							</uni-td>
							<uni-td>
								<view @click="selectsight('rns')">{{sightdata.rns}}</view>
							</uni-td>
							<uni-td>
								<view @click="selectsight('lns')">{{sightdata.lns}}</view>
							</uni-td>
						</uni-tr>
						<uni-tr>
							<uni-td>
								矫正视力
							</uni-td>
							<uni-td>
								<view @click="selectsight('rnc')">{{sightdata.rnc}}</view>
							</uni-td>
							<uni-td>
								<view @click="selectsight('lnc')">{{sightdata.lnc}}</view>
							</uni-td>
						</uni-tr>
					</uni-table>
					<view style="display: flex;justify-content: space-around; margin-top: 50rpx;">
						<cc-wxBtn :title="sightdata.servicename" style="width: 700rpx;"
							@menuClick="selectservice"></cc-wxBtn>
					</view>
					<view style="display: flex;justify-content: space-around; margin-top: 50rpx;">
						<view><button type="warn" size="mini" @click="addsightcancle">取消</button></view>
						<view><button type="primary" size="mini" @click="addsightsubmit">提交</button></view>
					</view>
				</view>
			</view>
		</uni-popup>
		<!-- 添加视力弹窗结束 -->

		<!-- 选择视力开始 -->
		<uni-popup ref="selectsightwindow">
			<view
				style="width: 50vw; max-width: 1000rpx; height: auto;  overflow-y: auto; max-height: 90vh; background-color: white; border-radius: 30rpx; padding: 30rpx;">
				<view>
					<cc-wxBtn v-for=" (item,index) in 视力列表" :key="index" :title="item.text"
						@menuClick="sightselectsubmit(item)"></cc-wxBtn>
				</view>
			</view>
		</uni-popup>
		<!-- 选择视力结束 -->

		<!-- 选择验光师开始 -->
		<uni-popup ref="selectservicewindow">
			<view
				style="width: 50vw; max-width: 1000rpx; height: auto; max-height: 90vh; background-color: white; border-radius: 30rpx; padding: 30rpx;">
				<view>
					<uni-search-bar v-model="searchkeyword" @input="geterpcorpaccount"></uni-search-bar>
					<view style="height: 80vh; overflow-y: auto;">
						<view v-for="(item,index) in erpcorpaccount" :key="index">
							<cc-wxBtn :title="item.name" @menuClick="operatselectsubmit(item)"></cc-wxBtn>
						</view>
					</view>
				</view>

			</view>
		</uni-popup>
		<!-- 选择验光师结束 -->

	</view>
</template>

<script>
	import m_excel from '../../uni_modules/m-excel/m-excel/js_sdk';
	import {
		postrequest
	} from '../../common/apis.js';
	export default {
		name: "MemberManage",
		props: {
			memberManageMembertype: null,
		},
		data() {
			return {
				sightdata: {},
				视力列表: [{
						value: '未检测',
						text: '未检测'
					},
					{
						value: '0.1',
						text: '0.1（4.0）'
					},
					{
						value: '0.12',
						text: '0.12（4.1）'
					},
					{
						value: '0.15',
						text: '0.15（4.2）'
					},
					{
						value: '0.2',
						text: '0.2（4.3）'
					},
					{
						value: '0.25',
						text: '0.25（4.4）'
					},
					{
						value: '0.3',
						text: '0.3（4.5）'
					},
					{
						value: '0.4',
						text: '0.4（4.6）'
					},
					{
						value: '0.5',
						text: '0.5（4.7）'
					},
					{
						value: '0.6',
						text: '0.6（4.8）'
					},
					{
						value: '0.8',
						text: '0.8（4.9）'
					},
					{
						value: '1.0',
						text: '1.0（5.0）'
					},
					{
						value: '1.2',
						text: '1.2（5.1）'
					},
					{
						value: '1.5',
						text: '1.5（5.2）'
					},
					{
						value: '2.0',
						text: '2.0（5.3）'
					}
				],
				addmembertitle: '添加会员',
				progresspercent: 0, //进度条比例
				sexrange: [{
					value: "1",
					text: "男"
				}, {
					value: "2",
					text: "女"
				}],
				currentDate: '',
				newmemberinfo: {},
				total: 0,
				page: 1,
				franchiselistpage: 1,
				franchiselisttotal: 0,
				memberdiopterlistpage: 1,
				memberdiopterlisttotal: 0,
				membersightlistpage: 1,
				membersightlisttotal: 0,
				memberlistpage: 1,
				memberlisttotal: 0,
				erpcorpaccountpage: 1, //账号列表数量
				erpcorpaccounttotal: 0, //账号列表数量
				memberbalancelog: {}, //会员余额日志
				memberbalancelogpage: 1,
				memberbalancelogtotal: 0,
				pagesize: 20,
				memberlist: '',
				currentmemberinfo: {},
				membersightlist: '',
				memberdiopterlist: '',
				viewcard: 'sight', //会员管理中弹窗显示sight为视力，diopter为屈光度
				memberindexs: '', //准备迁移的会员id列表
				franchiselist: '',
				erpcorpaccount: [], //账号列表
				searchkeyword: '', //搜索关键字
				operater: '', //积分操作人
				balanceoperatetype: '', //积分操作类型。余额、积分、代金券使用同一个功能，此参数区分具体是余额积分还是代金券
				balancenumber: 0, // 余额数量
				pointsnumber: 0, // 积分数量
				vouchernumber: 0, //代金券数量
				balanceremark: '', // 余额备注
				tmpurl: '', //临时API地址
				tmperrmessage: '', //临时API调用错误信息
				delaysearch: '', //延时搜索计时器
				shoplist: [], //下拉选择的加盟店列表
				searchkeyshopname: '', //按加盟店搜索时使用此字段
				exceldata: '',
				delaytimer: '',
				id_cardbak: '',
				percentnow: 0, //进度条当前进度
				percenttotal: 0, //进度条总数
				exportdatalist: [],
				exportdataindex: '',
				tempexportdata: '',
				currentsightselect: ''
			}
		},
		watch: {
			memberManageMembertype() {
				this.getmemberlist()
			}
		},
		mounted() {
			this.getmemberlist()
			uni.setStorageSync('currentPage', 'memberManage')
			uni.setStorageSync('currentPageName', '会员管理')
			this.getCurrentDate()
			this.initnewmemberinfo()
			this.initsight()
		},
		methods: {
			selectservice() {
				this.geterpcorpaccount()
				this.$refs.selectservicewindow.open('center')
			},
			geterpcorpaccount() {
				console.log(this.searchkeyword)
				let data = {
					username: uni.getStorageSync('username'),
					password: uni.getStorageSync('password'),
					page: 1,
					pagesize: this.pagesize,
					searchkeyword: this.searchkeyword
				}
				let url = 'https://www.jsyufang.com/yixun/api/get_erp_corp_account/index.asp'
				let errmessage = '获取账号列表接口调用失败'
				postrequest(url, data, errmessage, true)
					.then((res) => {
						console.log(res.data.data)
						this.erpcorpaccount = res.data.data
						this.total = res.data.total
					})
			},
			initsight() {
				this.sightdata = {
					rns: '未检测',
					lns: '未检测',
					rnc: '未检测',
					lnc: '未检测',
					member_id: 0,
					shop_accouint_id: 0,
					shop_id: 0,
					servicename: '请选择验光师'
				}
			},
			addsightcancle() {
				this.$refs.selectsightwindow.close()
			},
			sightselectsubmit(item) {
				console.log(item.text)
				this.$refs.selectsightwindow.close()
				if (this.currentsightselect == 'rns') {
					this.sightdata.rns = item.value
				}
				if (this.currentsightselect == 'lns') {
					this.sightdata.lns = item.value
				}
				if (this.currentsightselect == 'rnc') {
					this.sightdata.rnc = item.value
				}
				if (this.currentsightselect == 'lnc') {
					this.sightdata.lnc = item.value
				}
			},
			addsight() {
				this.$refs.addsightwindow.open('center')
				this.sightdata.member_id = this.currentmemberinfo.member_id
			},
			printinfo() {
				console.log(this.newmemberinfo.birthday)
				console.log(typeof this.newmemberinfo.birthday)
			},
			anastudent_no() {
				console.log('anastudent_no')
				this.newmemberinfo.id_card = ''
				this.newmemberinfo.gender = ''
				this.newmemberinfo.birthday = '请选择出生日期'
				let studentno = this.newmemberinfo.student_no
				if (studentno.length == 19) {
					if (studentno.substring(0, 1) == 'G' || studentno.substring(0, 1) == 'g') {
						this.newmemberinfo.id_card = studentno.substring(1, 19)
						let f = this.checkid_card()
						if (f == 1) {
							this.newmemberinfo.id_card = ''
						} else {
							this.checkid_card()
							this.$forceUpdate()
						}
					}
				}
			},
			anaid_card() {
				console.log(this.newmemberinfo.id_card.substring(17, 18))
				let f = parseInt(this.newmemberinfo.id_card.substring(17, 18)) % 2
				console.log(f)
				if (f == 0) {
					this.newmemberinfo.gender = '2'
				} else {
					this.newmemberinfo.gender = '1'
				}
				this.newmemberinfo.birthday = this.newmemberinfo.id_card.substring(6, 10) + '-' + this
					.newmemberinfo.id_card.substring(10, 12) + '-' + this.newmemberinfo.id_card.substring(12,
						14)
				if (this.newmemberinfo.birthday == '请选择出生日期') {
					this.newmemberinfo.birthday = ''
				}
			},
			initnewmemberinfo() {
				this.newmemberinfo = {
					name: '',
					mobile: '',
					gender: 0,
					id_card: '',
					shop_id: '',
					shop_name: '请选择加盟店',
					area_name: '请选择常住地区',
					birthday: '请选择出生日期',
					consumption: 0,
					voucher: 0,
					points: 0,
					balance: 0,
					basic_info: ''
				}
			},
			importmembercancle() {
				this.$refs.importmemberwindow.close()
			},
			importmembersubmit() {
				let that = this
				run()
				async function delay(time) {
					return new Promise(resolve => setTimeout(resolve, time));
				}
				async function run() {
					let titlemsg = ''
					if (!that.exceldata) {
						titlemsg = '请先选择导入文件'
					} else if (that.newmemberinfo.shop_id == '') {
						titlemsg = '请先选择加盟店'
					}
					if (titlemsg != '') {
						uni.showToast({
							title: titlemsg,
							icon: 'error'
						})
						return
					}
					that.$refs.progresspercentwindow.open('center')
					that.percenttotal = that.exceldata.length
					that.percentnow = 0
					for (let z = 0; z <= that.exceldata.length - 1; z++) {
						await delay(200);
						that.newmemberinfo.name = that.exceldata[z].姓名
						that.newmemberinfo.gender = that.exceldata[z].性别
						that.newmemberinfo.old_memberno = that.exceldata[z].原会员卡号
						that.newmemberinfo.balance = that.exceldata[z].余额
						that.newmemberinfo.points = that.exceldata[z].积分
						that.newmemberinfo.voucher = that.exceldata[z].代金券
						that.newmemberinfo.consumption = that.exceldata[z].消费总额
						that.newmemberinfo.school_name = that.exceldata[z].学校
						that.newmemberinfo.grade_name = that.exceldata[z].年级
						that.newmemberinfo.class_name = that.exceldata[z].班
						that.newmemberinfo.id_card = that.exceldata[z].身份证号
						that.newmemberinfo.student_no = that.exceldata[z].学籍号
						that.newmemberinfo.home_address = that.exceldata[z].家庭住址
						that.newmemberinfo.contacts = that.exceldata[z].联系人
						that.newmemberinfo.mobile = that.exceldata[z].手机号
						that.newmemberinfo.birthday = that.exceldata[z].出生日期
						that.newmemberinfo.basic_info = that.exceldata[z].备注
						that.newmemberinfo.act = 'addnew'
						let data = {
							username: uni.getStorageSync('username'),
							password: uni.getStorageSync('password'),
							...that.newmemberinfo
						}
						console.log(data)
						let url = 'https://www.jsyufang.com/yixun/api/addmember/index.asp'
						let errmessage = '添加会员接口调用失败'
						let aesdata = getApp().aesEncrypt(JSON.stringify(data), true)
						console.log('request')
						uni.request({
							url: url,
							method: 'POST',
							header: {
								'Content-Type': 'application/x-www-form-urlencoded'
							},
							data: {
								aesdata: aesdata
							},
							success: (res) => {
								if (res.data.msg) {
									that.exceldata[z].导入状态 = res.data.msg
									that.percentnow++
									that.progresspercent = parseInt((z / that
											.percenttotal) *
										100)
								} else {
									that.exceldata[z].导入状态 = '处理失败'
								}
							}
						})
					}
					that.$refs.progresspercentwindow.close()
					that.getmemberlist()
					uni.showModal({
						title: '导入完成',
						content: '请查看导入状态'
					})
				}
			},
			importmember() {
				this.newmemberinfo.shop_name = '请选择加盟店'
				this.newmemberinfo.id = ''
				this.$refs.importmemberwindow.open('center')
			},
			selectshop() {
				this.$refs.shopmanagewindow.open('center')
			},
			shopselectsubmit(item) {
				this.newmemberinfo.shop_name = item.company_name
				this.newmemberinfo.shop_id = item.id
				this.$refs.shopmanagewindow.close()
			},
			checkid_card() {
				let that = this
				console.log('checkid_card')
				let l = this.newmemberinfo.id_card.length
				for (let z = 0; z <= l - 1; z++) {
					let asc = this.newmemberinfo.id_card.substring(z, z + 1).charCodeAt(0)
					if ((asc >= 48 && asc <= 57) || asc == 120 || asc == 88) {} else {
						uni.showToast({
							title: that.newmemberinfo.id_card + '身份证号错误，请核实'
						})
						return 1
					}
				}
				let count = 0
				let idcard = this.newmemberinfo.id_card
				if (idcard != '') {
					let x = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
					let f = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2']
					for (let z = 0; z <= 16; z++) {
						let countx = idcard.substring(z, z + 1) * x[z]
						count = count + countx
					}
					if (f[count % 11] != this.newmemberinfo.id_card.substring(17, 18)) {
						uni.showToast({
							title: '请填写正确的身份证号',
							icon: 'error',
						})
						return
					}
					this.anaid_card()
				}
			},
			selectsight(v) {
				this.currentsightselect = v
				this.$refs.selectsightwindow.open('center')
			},
			getCurrentDate() {
				const date = new Date();
				const year = date.getFullYear();
				const month = (date.getMonth() + 1).toString().padStart(2, '0');
				const day = date.getDate().toString().padStart(2, '0');
				this.currentDate = `${year}-${month}-${day}`;
			},
			bindDateChange(e) {
				this.newmemberinfo.birthday = e.detail.value;
				this.$forceUpdate()
			},
			areaselectsubmit(item) {
				console.log(item.code)
				this.newmemberinfo.area_name = item.province + ',' + item.city + ',' + item.country
				this.newmemberinfo.area_code = item.code
				this.$refs.arealistwindow.close()
			},
			arealist() {
				this.$refs.arealistwindow.open('center')
			},
			addmembersubmit() {
				this.checkid_card()
				let data = {
					username: uni.getStorageSync('username'),
					password: uni.getStorageSync('password'),
					...this.newmemberinfo
				}
				let url = 'https://www.jsyufang.com/yixun/api/addmember/index.asp'
				let errmessage = '添加会员接口调用失败'
				postrequest(url, data, errmessage, true)
					.then((res) => {
						console.log(res.data.data)
						this.getmemberlist()
						let area_code = this.newmemberinfo.area_code
						let area_name = this.newmemberinfo.area_name
						let shop_id = this.newmemberinfo.shop_id
						let shop_name = this.newmemberinfo.shop_name
						this.initnewmemberinfo()
						this.newmemberinfo.area_code = area_code
						this.newmemberinfo.area_name = area_name
						this.newmemberinfo.shop_id = shop_id
						this.newmemberinfo.shop_name = shop_name
						this.$refs.addmemberwindow.close()
					})
			},
			addmembercancle() {
				if (this.newmemberinfo.act == 'edit') {
					let area_code = this.newmemberinfo.area_code
					let area_name = this.newmemberinfo.area_name
					let shop_id = this.newmemberinfo.shop_id
					let shop_name = this.newmemberinfo.shop_name
					this.initnewmemberinfo()
					this.newmemberinfo.area_code = area_code
					this.newmemberinfo.area_name = area_name
					this.newmemberinfo.shop_id = shop_id
					this.newmemberinfo.shop_name = shop_name
				}
				this.$refs.addmemberwindow.close()
			},
			addmember() {
				this.addmembertitle = '添加会员'
				this.$refs.addmemberwindow.open('center')
				this.newmemberinfo.act = 'addnew'
			},
			getshoplist() {
				this.getfranchiselist()
			},
			shopsearchchange(v) {
				console.log(this.shoplist[v.detail.value])
				this.searchkeyshopname = this.shoplist[v.detail.value]
				this.getmemberlist()
			},
			read() {
				let that = this
				uni.showModal({
					content: 'EXLCE文件记录数量请控制在1000条以内，否则可能会导致系统停止反应',
					title: '请确认数据文件信息',
					success(res) {
						if (res.confirm) {
							that.doread()
						}
					}
				})
			},
			doread() {
				uni.showLoading({
					title: '正在加载数据'
				})
				m_excel.read()
					.then((e) => {
						let that = this
						console.log(e);
						if (e.success == 1) {
							this.exceldata = e.data
							this.initnewmemberinfo()
							for (let z = 0; z <= this.exceldata.length - 1; z++) {
								if (this.exceldata[z].学籍号) {
									this.newmemberinfo.student_no = this.exceldata[z].学籍号
									this.anastudent_no()
								} else if (this.exceldata[z].身份证号) {
									this.newmemberinfo.id_card = this.exceldata[z].身份证号
									this.anaid_card()
								}
								this.exceldata[z].身份证号 = this.newmemberinfo.id_card
								if (this.newmemberinfo.gender == 1 || this.newmemberinfo.gender == 2) {
									this.exceldata[z].性别 = ['', '男', '女'][this.newmemberinfo.gender]
								}
								this.exceldata[z].出生日期 = this.newmemberinfo.birthday
								if (this.exceldata[z].出生日期 == '请选择出生日期') {
									this.exceldata[z].出生日期 = ''
								}
								if (!that.exceldata[z].余额) {
									that.exceldata[z].余额 = 0
								}
								if (!that.exceldata[z].积分) {
									that.exceldata[z].积分 = 0
								}
								if (!that.exceldata[z].代金券) {
									that.exceldata[z].代金券 = 0
								}
								if (!that.exceldata[z].消费总额) {
									that.exceldata[z].消费总额 = 0
								}
							}
						}
					})
					.catch((e) => {
						console.log(e);
					})
					.finally(uni.hideLoading())
			},
			put() {
				this.$refs.exportdatawindow.open('center')
			},
			exportselect(v) {
				console.log(v)
				this.exportdataindex = v
				let data = {
					username: uni.getStorageSync('username'),
					password: uni.getStorageSync('password'),
					page: v + 1,
					pagesize: 1000,
					memberManageMembertype: this.memberManageMembertype,
					searchkeyword: this.searchkeyword,
					searchkeyshopname: this.searchkeyshopname
				}
				let url = 'https://www.jsyufang.com/yiXun/api/get_erp_shop_member/index.asp'
				let errmessage = '获取会员列表接口调用失败'
				postrequest(url, data, errmessage, true)
					.then((res) => {
						console.log(res)
						this.tempexportdata = res.data.data
						this.doput()
					})
			},

			doput() {
				let that = this
				let excelfilecontent = []
				for (let z = 0; z < this.tempexportdata.length; z++) {
					excelfilecontent.push({
						'member_id': that.tempexportdata[z].member_id,
						'加盟店': that.tempexportdata[z].shop_name,
						'姓名': that.tempexportdata[z].name,
						'性别': ['', '男', '女'][that.tempexportdata[z].gender],
						'手机号': that.tempexportdata[z].mobile,
						'余额': that.tempexportdata[z].balance,
						'积分': that.tempexportdata[z].points,
						'代金券': that.tempexportdata[z].voucher,
						'消费总额': that.tempexportdata[z].consumption,
						'所在地区': that.tempexportdata[z].area_name,
						'身份证号': that.tempexportdata[z].id_card,
						'生日': that.tempexportdata[z].birthday,
						'学校': that.tempexportdata[z].school_name,
						'年级': that.tempexportdata[z].grade_name,
						'班': that.tempexportdata[z].class_name,
						'家庭住址': that.tempexportdata[z].home_address,
						'注册时间': that.tempexportdata[z].create_time
					})
				}
				uni.setStorageSync('excelfilename', '会员列表.xlsx')
				m_excel.put(excelfilecontent).then((e) => {
					console.log(e);
					uni.showToast({
						title: e.msg
					})
				})
			},
			searchkeywordchange() {
				clearTimeout(this.delaysearch)
				this.delaysearch = setTimeout(() => {
					this.getmemberlist()
				}, 1000)
			},
			popwindow(v) {
				uni.setStorageSync('currentmemberinfo', this.currentmemberinfo)
				this.$emit('popwindow', v)
			},
			balancecancle() {
				this.$refs.addmemberbalancelog.close()
			},
			balancesubmit() {
				if (this.balancenumber == 0) {
					uni.showToast({
						title: '操作数量不可为0',
						icon: 'error'
					})
					return
				}
				if (this.balanceremark == '') {
					uni.showToast({
						title: '请填写备注信息',
						icon: 'error'
					})
					return
				}
				if (!this.operater.id) {
					uni.showToast({
						title: '请选择操作人',
						icon: 'error'
					})
					return
				}
				let data = {
					username: uni.getStorageSync('username'),
					password: uni.getStorageSync('password'),
					member_id: this.currentmemberinfo.member_id,
					number: this.balancenumber,
					remark: this.balanceremark,
					operater: this.operater.id
				}
				let url = 'https://www.jsyufang.com/yixun/api/addbalancelog/index.asp'
				let errmessage = '添加余额日志接口调用失败'
				postrequest(url, data, errmessage, true)
					.then((res) => {
						console.log(res.data.data)
						this.getmemberbalancelog(this.currentmemberinfo)
						this.getmemberlist()
						this.$refs.addmemberbalancelog.close()
					})
			},
			operatselectsubmit(item) {
				this.operater = item
				this.$refs.selectmemberbalancewindow.close()
			},
			selecterpcorpaccount() {
				this.geterpcorpaccount()
				this.$refs.selectmemberbalancewindow.open('center')
			},
			addmemberbalancelog() {
				this.$refs.addmemberbalancelog.open('center')
			},
			getmemberbalancelog(item) {
				this.memberbalancelog = []
				this.currentmemberinfo = item
				console.log(item)
				let data = {
					username: uni.getStorageSync('username'),
					password: uni.getStorageSync('password'),
					member_id: item.member_id,
					page: 1,
					pagesize: this.pagesize
				}
				let url = 'https://www.jsyufang.com/yixun/api/getmemberbalancelog/index.asp'
				let errmessage = '获取会员余额日志接口调用失败'
				postrequest(url, data, errmessage, true)
					.then((res) => {
						console.log(res.data.data)
						this.memberbalancelog = res.data.data
						this.memberbalancelogtotal = res.data.total
					})
			},
			geterpcorpaccount() {
				console.log(this.searchkeyword)
				let data = {
					username: uni.getStorageSync('username'),
					password: uni.getStorageSync('password'),
					page: 1,
					pagesize: this.pagesize,
					searchkeyword: this.searchkeyword
				}
				let url = 'https://www.jsyufang.com/yixun/api/get_erp_corp_account/index.asp'
				let errmessage = '获取会员余额日志接口调用失败'
				postrequest(url, data, errmessage, true)
					.then((res) => {
						console.log(res.data.data)
						this.erpcorpaccount = res.data.data
						this.erpcorpaccounttotal = res.data.total
					})

			},
			balance(item) {
				this.balanceoperatetype = '余额管理'
				this.getmemberbalancelog(item)
				this.$refs.memberbalance.open('center')
			},
			getfranchiselist() {
				console.log('getfranchiselist')
				let data = {
					username: uni.getStorageSync('username'),
					password: uni.getStorageSync('password'),
					page: 1,
					pagesize: this.pagesize,
					searchkeyword: this.searchkeyword,
					searchfield: this.searchfield
				}
				let url = 'https://www.jsyufang.com/yiXun/api/get_erp_corp_shop/index.asp'
				let errmessage = '获取加盟店列表接口调用失败'
				postrequest(url, data, errmessage, true)
					.then((res) => {
						console.log(res.data.data)
						this.franchiselist = res.data.data
						this.franchiselisttotal = res.data.total
						this.shoplist = ['全部']
						for (let z = 0; z < this.franchiselist.length; z++) {
							this.shoplist.push(this.franchiselist[z].name)
						}
						console.log(this.shoplist)
						this.searchfield = ''
					})
			},
			cancelSelection() {
				this.tableData.forEach(item => {
					item.selected = false; // 取消所有项的选择状态
				})
			},
			memberManageSubmit(item) {
				let that = this
				console.log(item.id)
				this.objectshop = item
				this.$refs.memberManagewindow.close()
				uni.showModal({
					title: '确认会员迁移信息',
					content: '确认要将此' + this.memberindexs.length + '人迁移到' + this.objectshop.company_name,
					success(res) {
						if (res.confirm) {
							that.domemberMigrate(that.memberindexs, that.objectshop)
						}
					}
				})
			},
			domemberMigrate(memberindexs, objectshop) {
				let membertomigrate = []
				for (let z = 0; z < this.memberindexs.length; z++) {
					console.log(this.memberlist[this.memberindexs[z]].id)
					membertomigrate.push(this.memberlist[this.memberindexs[z]].id)
				}
				let data = {
					username: uni.getStorageSync('username'),
					password: uni.getStorageSync('password'),
					memberindexs: membertomigrate,
					objectshop: objectshop.id
				}
				let url = 'https://www.jsyufang.com/yixun/api/memberMigrate/index.asp'
				let errmessage = '迁移用户接口调用失败'
				postrequest(url, data, errmessage, true)
					.then((res) => {
						this.getmemberlist()
						console.log(res)
					})
			},
			memberMigrate() {
				let that = this
				if (this.memberindexs.length == -0) {
					uni.showToast({
						title: '请先选中拟迁移的会员',
						icon: 'error'
					})
				} else {
					that.getfranchiselist()
					that.$refs.memberManagewindow.open('center')
					// 	uni.showModal({
					// 		title: '迁移会员警告',
					// 		content: '此操作将会将会迁移已选中的' + this.memberindexs.length + '名会员',
					// 		success(res) {
					// 			if (res.confirm) {
					// 					that.getfranchiselist()
					// 					that.$refs.memberManagewindow.open('center')
					// 			}
					// 		}
					// 	})
				}
			},
			cleartableselect() {
				this.$refs.memberlisttable.clearSelection()
			},
			membertableselectionchange(e) {
				this.memberindexs = e.detail.index
				for (let z = 0; z < this.memberindexs.length; z++) {
					console.log(this.memberlist[this.memberindexs[z]].id)
				}
			},
			popfunctionwindow(item) {
				console.log(item)
				this.currentmemberinfo = item
				this.$refs.functionwindow.open('left')
			},
			diopterlog() {
				this.viewcard = '屈光度检查记录'
				let member_id = this.currentmemberinfo.member_id
				let data = {
					username: uni.getStorageSync('username'),
					password: uni.getStorageSync('password'),
					// page: this.page,
					// pagesize: this.pagesize,
					page: 1,
					pagesize: 100,
					member_id: member_id
				}
				let url = "https://www.jsyufang.com/yiXun/api/get_erp_report_member_diopter/index.asp"
				let errmessage = "获取会员屈光度加测数据接口调用失败"
				postrequest(url, data, errmessage, true)
					.then((res) => {
						console.log(res.data.data)
						this.memberdiopterlist = res.data.data
						this.memberdiopterlisttotal = res.data.total
						this.$forceUpdate()
					})
			},
			selfsightlog() {
				this.viewcard = '视力自测记录'
				let member_id = this.currentmemberinfo.member_id
				let data = {
					username: uni.getStorageSync('username'),
					password: uni.getStorageSync('password'),
					// page: this.page,
					// pagesize: this.pagesize,
					page: 1,
					pagesize: 100,
					member_id: member_id
				}
				let url = "https://www.jsyufang.com/yiXun/api/get_erp_report_member_sight_self/index.asp"
				let errmessage = "获取会员自测视力数据接口调用失败"
				postrequest(url, data, errmessage, true)
					.then((res) => {
						console.log(res.data.data)
						this.membersightlist = res.data.data
						this.membersightlisttotal = res.data.total
						this.$forceUpdate()
					})

			},
			sightlog() {
				this.viewcard = '视力检查记录'
				let member_id = this.currentmemberinfo.member_id
				let data = {
					username: uni.getStorageSync('username'),
					password: uni.getStorageSync('password'),
					// page: this.page,
					// pagesize: this.pagesize,
					page: 1,
					pagesize: 100,
					member_id: member_id
				}
				let url = "https://www.jsyufang.com/yiXun/api/get_erp_report_member_sight/index.asp"
				let errmessage = "获取会员视力数据接口调用失败"
				postrequest(url, data, errmessage, true)
					.then((res) => {
						console.log(res.data)
						this.membersightlist = res.data.data
						this.membersightlisttotal = res.data.total
						this.$forceUpdate()
					})
			},
			viewme() {
				// this.$refs.functionwindow.close()
				// this.currentmemberinfo = item
				this.$refs.viewSightDiopterLog.open('center')
				this.sightlog()
			},
			editme(item) {
				// this.$refs.functionwindow.close()
				this.$refs.addmemberwindow.open('center')
				this.addmembertitle = '修改会员信息'
				this.newmemberinfo = item
				this.newmemberinfo.act = 'edit'
			},
			delme(item) {
				let that = this
				uni.showModal({
					title: '警告：信息删除后将无法恢复，请谨慎操作',
					content: '确认删除' + item.name + '信息',
					success(res) {
						if (res.confirm) {
							that.dodel(item)
						}
					}
				})
			},
			dodel(item) {
				let data = {
					...item
				}
				let url = 'https://www.jsyufang.com/yiXun/api/del_erp_corp_shop_member/index.asp'
				let errmessage = '删除会员信息接口调用失败'
				postrequest(url, data, errmessage, true)
					.then((res) => {
						uni.showToast({
							title: res.data.msg
						})
						this.$refs.functionwindow.close()
						this.getmemberlist()
						this.$forceUpdate()
					})
			},
			memberlistpagepagechange(e) {
				this.memberlistpage = e
				if (e != '') {
					this.getmemberlist()
				}
			},
			getmemberlist() {
				let that = this
				if (this.searchkeyshopname == '全部') {
					this.searchkeyshopname = ''
				}
				let data = {
					username: uni.getStorageSync('username'),
					password: uni.getStorageSync('password'),
					page: this.memberlistpage,
					pagesize: this.pagesize,
					memberManageMembertype: this.memberManageMembertype,
					searchkeyword: this.searchkeyword,
					searchkeyshopname: this.searchkeyshopname
				}
				let url = 'https://www.jsyufang.com/yiXun/api/get_erp_shop_member/index.asp'
				let errmessage = '获取会员列表接口调用失败'
				postrequest(url, data, errmessage, true)
					.then((res) => {
						console.log(res)
						this.exportdatalist = []
						this.memberlist = res.data.data
						this.memberlisttotal = res.data.total
						for (let z = 0; z <= this.memberlisttotal / 1000; z++) {
							this.exportdatalist.push(z)
						}
						that.cleartableselect()
						console.log(this.memberlist)
					})
			}
		}
	}
</script>

<style>
	.table-container {
		height: 78vh;
		/* 设置固定高度 */
		overflow-y: auto;
		/* 启用垂直滚动 */
	}

	.popwindowstyle {
		width: 500rpx;
		height: auto;
		max-height: 90vh;
		background-color: white;
		border-radius: 30rpx;
		padding: 30rpx;
		justify-content: center;
		overflow-y: auto;
	}
</style>